# Copyright 2024 仲夏叶.
# SPDX-License-Identifier: Apache-2.0docker

FROM node:lts-bookworm

RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list.d/debian.sources && \
    apt update && \
    apt install -y git git-lfs git-flow git-svn bash zsh curl wget tree vim sudo && \
    apt autoremove && \
    apt autoclean && \
    npm config set registry https://registry.npmmirror.com && \
    npm install -g npm pnpm && \
    mkdir /workspaces && \
    echo "node ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers && \
    chown -R node:node /workspaces && \
    USER=node HOME=/home/node ZDOTDIR=/home/node ZSH=/home/node/.oh-my-zsh REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
    git clone --depth 1 --single-branch https://github.com/zsh-users/zsh-autosuggestions /home/node/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \
    git clone --depth 1 --single-branch https://github.com/zsh-users/zsh-syntax-highlighting /home/node/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \
    git clone --depth 1 --single-branch https://github.com/zsh-users/zsh-completions /home/node/.oh-my-zsh/custom/plugins/zsh-completions && \
    sed -i 's/plugins=(git)/plugins=(git git-flow-avh git-lfs zsh-autosuggestions zsh-syntax-highlighting zsh-completions)/g' /home/node/.zshrc && \
    sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="agnoster"/g' /home/node/.zshrc

USER node:node
WORKDIR /workspaces

CMD ["/usr/local/bin/node"]
